<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - code analysis - /usr/include/boost/random/exponential_distribution.hpp</title>
  <link rel="stylesheet" type="text/css" href="../../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../../../index.html">top level</a> - <a href="index.html">usr/include/boost/random</a> - exponential_distribution.hpp<span style="font-size: 80%;"> (source / <a href="exponential_distribution.hpp.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">code analysis</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">4</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2020-09-11 22:25:26</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">2</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : /* boost random/exponential_distribution.hpp header file</a>
<span class="lineNum">       2 </span>            :  *
<span class="lineNum">       3 </span>            :  * Copyright Jens Maurer 2000-2001
<span class="lineNum">       4 </span>            :  * Copyright Steven Watanabe 2011
<span class="lineNum">       5 </span>            :  * Distributed under the Boost Software License, Version 1.0. (See
<span class="lineNum">       6 </span>            :  * accompanying file LICENSE_1_0.txt or copy at
<span class="lineNum">       7 </span>            :  * http://www.boost.org/LICENSE_1_0.txt)
<span class="lineNum">       8 </span>            :  *
<span class="lineNum">       9 </span>            :  * See http://www.boost.org for most recent version including documentation.
<span class="lineNum">      10 </span>            :  *
<span class="lineNum">      11 </span>            :  * $Id$
<span class="lineNum">      12 </span>            :  *
<span class="lineNum">      13 </span>            :  * Revision history
<span class="lineNum">      14 </span>            :  *  2001-02-18  moved to individual header files
<span class="lineNum">      15 </span>            :  */
<span class="lineNum">      16 </span>            : 
<span class="lineNum">      17 </span>            : #ifndef BOOST_RANDOM_EXPONENTIAL_DISTRIBUTION_HPP
<span class="lineNum">      18 </span>            : #define BOOST_RANDOM_EXPONENTIAL_DISTRIBUTION_HPP
<span class="lineNum">      19 </span>            : 
<span class="lineNum">      20 </span>            : #include &lt;boost/config/no_tr1/cmath.hpp&gt;
<span class="lineNum">      21 </span>            : #include &lt;iosfwd&gt;
<span class="lineNum">      22 </span>            : #include &lt;boost/assert.hpp&gt;
<span class="lineNum">      23 </span>            : #include &lt;boost/limits.hpp&gt;
<span class="lineNum">      24 </span>            : #include &lt;boost/random/detail/config.hpp&gt;
<span class="lineNum">      25 </span>            : #include &lt;boost/random/detail/operators.hpp&gt;
<span class="lineNum">      26 </span>            : #include &lt;boost/random/uniform_01.hpp&gt;
<span class="lineNum">      27 </span>            : 
<span class="lineNum">      28 </span>            : namespace boost {
<span class="lineNum">      29 </span>            : namespace random {
<span class="lineNum">      30 </span>            : 
<span class="lineNum">      31 </span>            : /**
<span class="lineNum">      32 </span>            :  * The exponential distribution is a model of \random_distribution with
<span class="lineNum">      33 </span>            :  * a single parameter lambda.
<span class="lineNum">      34 </span>            :  *
<span class="lineNum">      35 </span>            :  * It has \f$\displaystyle p(x) = \lambda e^{-\lambda x}\f$
<span class="lineNum">      36 </span>            :  */
<span class="lineNum">      37 </span>            : template&lt;class RealType = double&gt;
<span class="lineNum">      38 </span>            : class exponential_distribution
<span class="lineNum">      39 </span>            : {
<span class="lineNum">      40 </span>            : public:
<span class="lineNum">      41 </span>            :     typedef RealType input_type;
<span class="lineNum">      42 </span>            :     typedef RealType result_type;
<span class="lineNum">      43 </span>            : 
<span class="lineNum">      44 </span>            :     class param_type
<span class="lineNum">      45 </span>            :     {
<span class="lineNum">      46 </span>            :     public:
<span class="lineNum">      47 </span>            : 
<span class="lineNum">      48 </span>            :         typedef exponential_distribution distribution_type;
<span class="lineNum">      49 </span>            : 
<span class="lineNum">      50 </span>            :         /**
<span class="lineNum">      51 </span>            :          * Constructs parameters with a given lambda.
<span class="lineNum">      52 </span>            :          *
<span class="lineNum">      53 </span>            :          * Requires: lambda &gt; 0
<span class="lineNum">      54 </span>            :          */
<span class="lineNum">      55 </span>            :         param_type(RealType lambda_arg = RealType(1.0))
<span class="lineNum">      56 </span>            :           : _lambda(lambda_arg) { BOOST_ASSERT(_lambda &gt; RealType(0)); }
<span class="lineNum">      57 </span>            : 
<span class="lineNum">      58 </span>            :         /** Returns the lambda parameter of the distribution. */
<span class="lineNum">      59 </span>            :         RealType lambda() const { return _lambda; }
<span class="lineNum">      60 </span>            : 
<span class="lineNum">      61 </span>            :         /** Writes the parameters to a @c std::ostream. */
<span class="lineNum">      62 </span>            :         BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, param_type, parm)
<span class="lineNum">      63 </span>            :         {
<span class="lineNum">      64 </span>            :             os &lt;&lt; parm._lambda;
<span class="lineNum">      65 </span>            :             return os;
<span class="lineNum">      66 </span>            :         }
<span class="lineNum">      67 </span>            :         
<span class="lineNum">      68 </span>            :         /** Reads the parameters from a @c std::istream. */
<span class="lineNum">      69 </span>            :         BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, param_type, parm)
<span class="lineNum">      70 </span>            :         {
<span class="lineNum">      71 </span>            :             is &gt;&gt; parm._lambda;
<span class="lineNum">      72 </span>            :             return is;
<span class="lineNum">      73 </span>            :         }
<span class="lineNum">      74 </span>            : 
<span class="lineNum">      75 </span>            :         /** Returns true if the two sets of parameters are equal. */
<span class="lineNum">      76 </span>            :         BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(param_type, lhs, rhs)
<span class="lineNum">      77 </span>            :         { return lhs._lambda == rhs._lambda; }
<span class="lineNum">      78 </span>            : 
<span class="lineNum">      79 </span>            :         /** Returns true if the two sets of parameters are different. */
<span class="lineNum">      80 </span>            :         BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(param_type)
<span class="lineNum">      81 </span>            : 
<span class="lineNum">      82 </span>            :     private:
<span class="lineNum">      83 </span>            :         RealType _lambda;
<span class="lineNum">      84 </span>            :     };
<span class="lineNum">      85 </span>            : 
<span class="lineNum">      86 </span>            :     /**
<span class="lineNum">      87 </span>            :      * Constructs an exponential_distribution with a given lambda.
<span class="lineNum">      88 </span>            :      *
<span class="lineNum">      89 </span>            :      * Requires: lambda &gt; 0
<span class="lineNum">      90 </span>            :      */
<span class="lineNum">      91 </span>            :     explicit exponential_distribution(RealType lambda_arg = RealType(1.0))
<span class="lineNum">      92 </span><span class="lineNoCov">          0 :       : _lambda(lambda_arg) { BOOST_ASSERT(_lambda &gt; RealType(0)); }</span>
<span class="lineNum">      93 </span>            : 
<span class="lineNum">      94 </span>            :     /**
<span class="lineNum">      95 </span>            :      * Constructs an exponential_distribution from its parameters
<span class="lineNum">      96 </span>            :      */
<span class="lineNum">      97 </span>            :     explicit exponential_distribution(const param_type&amp; parm)
<span class="lineNum">      98 </span>            :       : _lambda(parm.lambda()) {}
<span class="lineNum">      99 </span>            : 
<span class="lineNum">     100 </span>            :     // compiler-generated copy ctor and assignment operator are fine
<span class="lineNum">     101 </span>            : 
<span class="lineNum">     102 </span>            :     /** Returns the lambda parameter of the distribution. */
<span class="lineNum">     103 </span>            :     RealType lambda() const { return _lambda; }
<span class="lineNum">     104 </span>            : 
<span class="lineNum">     105 </span>            :     /** Returns the smallest value that the distribution can produce. */
<span class="lineNum">     106 </span>            :     RealType min BOOST_PREVENT_MACRO_SUBSTITUTION () const
<span class="lineNum">     107 </span>            :     { return RealType(0); }
<span class="lineNum">     108 </span>            :     /** Returns the largest value that the distribution can produce. */
<span class="lineNum">     109 </span>            :     RealType max BOOST_PREVENT_MACRO_SUBSTITUTION () const
<span class="lineNum">     110 </span>            :     { return (std::numeric_limits&lt;RealType&gt;::infinity)(); }
<span class="lineNum">     111 </span>            : 
<span class="lineNum">     112 </span>            :     /** Returns the parameters of the distribution. */
<span class="lineNum">     113 </span>            :     param_type param() const { return param_type(_lambda); }
<span class="lineNum">     114 </span>            :     /** Sets the parameters of the distribution. */
<span class="lineNum">     115 </span>            :     void param(const param_type&amp; parm) { _lambda = parm.lambda(); }
<span class="lineNum">     116 </span>            : 
<span class="lineNum">     117 </span>            :     /**
<span class="lineNum">     118 </span>            :      * Effects: Subsequent uses of the distribution do not depend
<span class="lineNum">     119 </span>            :      * on values produced by any engine prior to invoking reset.
<span class="lineNum">     120 </span>            :      */
<span class="lineNum">     121 </span>            :     void reset() { }
<span class="lineNum">     122 </span>            : 
<span class="lineNum">     123 </span>            :     /**
<span class="lineNum">     124 </span>            :      * Returns a random variate distributed according to the
<span class="lineNum">     125 </span>            :      * exponential distribution.
<a name="126"><span class="lineNum">     126 </span>            :      */</a>
<span class="lineNum">     127 </span>            :     template&lt;class Engine&gt;
<span class="lineNum">     128 </span><span class="lineNoCov">          0 :     result_type operator()(Engine&amp; eng) const</span>
<span class="lineNum">     129 </span>            :     { 
<span class="lineNum">     130 </span>            :         using std::log;
<span class="lineNum">     131 </span><span class="lineNoCov">          0 :         return -result_type(1) /</span>
<span class="lineNum">     132 </span><span class="lineNoCov">          0 :             _lambda * log(result_type(1)-uniform_01&lt;RealType&gt;()(eng));</span>
<span class="lineNum">     133 </span>            :     }
<span class="lineNum">     134 </span>            : 
<span class="lineNum">     135 </span>            :     /**
<span class="lineNum">     136 </span>            :      * Returns a random variate distributed according to the exponential
<span class="lineNum">     137 </span>            :      * distribution with parameters specified by param.
<span class="lineNum">     138 </span>            :      */
<span class="lineNum">     139 </span>            :     template&lt;class Engine&gt;
<span class="lineNum">     140 </span>            :     result_type operator()(Engine&amp; eng, const param_type&amp; parm) const
<span class="lineNum">     141 </span>            :     { 
<span class="lineNum">     142 </span>            :         return exponential_distribution(parm)(eng);
<span class="lineNum">     143 </span>            :     }
<span class="lineNum">     144 </span>            : 
<span class="lineNum">     145 </span>            :     /** Writes the distribution to a std::ostream. */
<span class="lineNum">     146 </span>            :     BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, exponential_distribution, ed)
<span class="lineNum">     147 </span>            :     {
<span class="lineNum">     148 </span>            :         os &lt;&lt; ed._lambda;
<span class="lineNum">     149 </span>            :         return os;
<span class="lineNum">     150 </span>            :     }
<span class="lineNum">     151 </span>            : 
<span class="lineNum">     152 </span>            :     /** Reads the distribution from a std::istream. */
<span class="lineNum">     153 </span>            :     BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, exponential_distribution, ed)
<span class="lineNum">     154 </span>            :     {
<span class="lineNum">     155 </span>            :         is &gt;&gt; ed._lambda;
<span class="lineNum">     156 </span>            :         return is;
<span class="lineNum">     157 </span>            :     }
<span class="lineNum">     158 </span>            : 
<span class="lineNum">     159 </span>            :     /**
<span class="lineNum">     160 </span>            :      * Returns true iff the two distributions will produce identical
<span class="lineNum">     161 </span>            :      * sequences of values given equal generators.
<span class="lineNum">     162 </span>            :      */
<span class="lineNum">     163 </span>            :     BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(exponential_distribution, lhs, rhs)
<span class="lineNum">     164 </span>            :     { return lhs._lambda == rhs._lambda; }
<span class="lineNum">     165 </span>            :     
<span class="lineNum">     166 </span>            :     /**
<span class="lineNum">     167 </span>            :      * Returns true iff the two distributions will produce different
<span class="lineNum">     168 </span>            :      * sequences of values given equal generators.
<span class="lineNum">     169 </span>            :      */
<span class="lineNum">     170 </span>            :     BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(exponential_distribution)
<span class="lineNum">     171 </span>            : 
<span class="lineNum">     172 </span>            : private:
<span class="lineNum">     173 </span>            :     result_type _lambda;
<span class="lineNum">     174 </span>            : };
<span class="lineNum">     175 </span>            : 
<span class="lineNum">     176 </span>            : } // namespace random
<span class="lineNum">     177 </span>            : 
<span class="lineNum">     178 </span>            : using random::exponential_distribution;
<span class="lineNum">     179 </span>            : 
<span class="lineNum">     180 </span>            : } // namespace boost
<span class="lineNum">     181 </span>            : 
<span class="lineNum">     182 </span>            : #endif // BOOST_RANDOM_EXPONENTIAL_DISTRIBUTION_HPP
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.12</a></td></tr>
  </table>
  <br>

</body>
</html>
